home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ntfs-3g / volume.h < prev   
Encoding:
C/C++ Source or Header  |  2008-10-26  |  8.2 KB  |  243 lines

  1. /*
  2.  * volume.h - Exports for NTFS volume handling. Originated from the Linux-NTFS project.
  3.  *
  4.  * Copyright (c) 2000-2004 Anton Altaparmakov
  5.  * Copyright (c) 2004-2005 Richard Russon
  6.  * Copyright (c) 2005-2006 Yura Pakhuchiy
  7.  * Copyright (c) 2005-2008 Szabolcs Szakacsits
  8.  *
  9.  * This program/include file is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License as published
  11.  * by the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  *
  14.  * This program/include file is distributed in the hope that it will be
  15.  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  16.  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program (in the main directory of the NTFS-3G
  21.  * distribution in the file COPYING); if not, write to the Free Software
  22.  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23.  */
  24.  
  25. #ifndef _NTFS_VOLUME_H
  26. #define _NTFS_VOLUME_H
  27.  
  28. #ifdef HAVE_CONFIG_H
  29. #include "config.h"
  30. #endif
  31.  
  32. #ifdef HAVE_STDIO_H
  33. #include <stdio.h>
  34. #endif
  35. #ifdef HAVE_SYS_PARAM_H
  36. #include <sys/param.h>
  37. #endif
  38. #ifdef HAVE_SYS_MOUNT_H
  39. #include <sys/mount.h>
  40. #endif
  41. #ifdef HAVE_MNTENT_H
  42. #include <mntent.h>
  43. #endif
  44.  
  45. /*
  46.  * Under Cygwin, DJGPP and FreeBSD we do not have MS_RDONLY,
  47.  * so we define them ourselves.
  48.  */
  49. #ifndef MS_RDONLY
  50. #define MS_RDONLY 1
  51. #endif
  52.  
  53. #define MS_EXCLUSIVE 0x08000000
  54.  
  55. #ifndef MS_FORCE
  56. #define MS_FORCE     0x10000000
  57. #endif
  58.  
  59. #define MS_IGNORE_HIBERFILE   0x20000000
  60.  
  61. /* Forward declaration */
  62. typedef struct _ntfs_volume ntfs_volume;
  63.  
  64. #include "types.h"
  65. #include "support.h"
  66. #include "device.h"
  67. #include "inode.h"
  68. #include "attrib.h"
  69.  
  70. /**
  71.  * enum ntfs_mount_flags -
  72.  *
  73.  * Flags returned by the ntfs_check_if_mounted() function.
  74.  */
  75. typedef enum {
  76.     NTFS_MF_MOUNTED        = 1,    /* Device is mounted. */
  77.     NTFS_MF_ISROOT        = 2,    /* Device is mounted as system root. */
  78.     NTFS_MF_READONLY    = 4,    /* Device is mounted read-only. */
  79. } ntfs_mount_flags;
  80.  
  81. extern int ntfs_check_if_mounted(const char *file, unsigned long *mnt_flags);
  82.  
  83. typedef enum {
  84.     NTFS_VOLUME_OK            = 0,
  85.     NTFS_VOLUME_SYNTAX_ERROR    = 11,
  86.     NTFS_VOLUME_NOT_NTFS        = 12,
  87.     NTFS_VOLUME_CORRUPT        = 13,
  88.     NTFS_VOLUME_HIBERNATED        = 14,
  89.     NTFS_VOLUME_UNCLEAN_UNMOUNT    = 15,
  90.     NTFS_VOLUME_LOCKED        = 16,
  91.     NTFS_VOLUME_RAID        = 17,
  92.     NTFS_VOLUME_UNKNOWN_REASON    = 18,
  93.     NTFS_VOLUME_NO_PRIVILEGE    = 19,
  94.     NTFS_VOLUME_OUT_OF_MEMORY    = 20,
  95.     NTFS_VOLUME_FUSE_ERROR        = 21,
  96.     NTFS_VOLUME_INSECURE        = 22
  97. } ntfs_volume_status;
  98.  
  99. /**
  100.  * enum ntfs_volume_state_bits -
  101.  *
  102.  * Defined bits for the state field in the ntfs_volume structure.
  103.  */
  104. typedef enum {
  105.     NV_ReadOnly,        /* 1: Volume is read-only. */
  106.     NV_CaseSensitive,    /* 1: Volume is mounted case-sensitive. */
  107.     NV_LogFileEmpty,    /* 1: $logFile journal is empty. */
  108. } ntfs_volume_state_bits;
  109.  
  110. #define  test_nvol_flag(nv, flag)     test_bit(NV_##flag, (nv)->state)
  111. #define   set_nvol_flag(nv, flag)      set_bit(NV_##flag, (nv)->state)
  112. #define clear_nvol_flag(nv, flag)    clear_bit(NV_##flag, (nv)->state)
  113.  
  114. #define NVolReadOnly(nv)         test_nvol_flag(nv, ReadOnly)
  115. #define NVolSetReadOnly(nv)          set_nvol_flag(nv, ReadOnly)
  116. #define NVolClearReadOnly(nv)        clear_nvol_flag(nv, ReadOnly)
  117.  
  118. #define NVolCaseSensitive(nv)         test_nvol_flag(nv, CaseSensitive)
  119. #define NVolSetCaseSensitive(nv)      set_nvol_flag(nv, CaseSensitive)
  120. #define NVolClearCaseSensitive(nv)    clear_nvol_flag(nv, CaseSensitive)
  121.  
  122. #define NVolLogFileEmpty(nv)         test_nvol_flag(nv, LogFileEmpty)
  123. #define NVolSetLogFileEmpty(nv)          set_nvol_flag(nv, LogFileEmpty)
  124. #define NVolClearLogFileEmpty(nv)    clear_nvol_flag(nv, LogFileEmpty)
  125.  
  126. /*
  127.  * NTFS version 1.1 and 1.2 are used by Windows NT4.
  128.  * NTFS version 2.x is used by Windows 2000 Beta
  129.  * NTFS version 3.0 is used by Windows 2000.
  130.  * NTFS version 3.1 is used by Windows XP, 2003 and Vista.
  131.  */
  132.  
  133. #define NTFS_V1_1(major, minor) ((major) == 1 && (minor) == 1)
  134. #define NTFS_V1_2(major, minor) ((major) == 1 && (minor) == 2)
  135. #define NTFS_V2_X(major, minor) ((major) == 2)
  136. #define NTFS_V3_0(major, minor) ((major) == 3 && (minor) == 0)
  137. #define NTFS_V3_1(major, minor) ((major) == 3 && (minor) == 1)
  138.  
  139. #define NTFS_BUF_SIZE 8192
  140.  
  141. /**
  142.  * struct _ntfs_volume - structure describing an open volume in memory.
  143.  */
  144. struct _ntfs_volume {
  145.     union {
  146.         struct ntfs_device *dev;    /* NTFS device associated with
  147.                            the volume. */
  148.         void *sb;    /* For kernel porting compatibility. */
  149.     };
  150.     char *vol_name;        /* Name of the volume. */
  151.     unsigned long state;    /* NTFS specific flags describing this volume.
  152.                    See ntfs_volume_state_bits above. */
  153.  
  154.     ntfs_inode *vol_ni;    /* ntfs_inode structure for FILE_Volume. */
  155.     u8 major_ver;        /* Ntfs major version of volume. */
  156.     u8 minor_ver;        /* Ntfs minor version of volume. */
  157.     u16 flags;        /* Bit array of VOLUME_* flags. */
  158.  
  159.     u16 sector_size;    /* Byte size of a sector. */
  160.     u8 sector_size_bits;    /* Log(2) of the byte size of a sector. */
  161.     u32 cluster_size;    /* Byte size of a cluster. */
  162.     u32 mft_record_size;    /* Byte size of a mft record. */
  163.     u32 indx_record_size;    /* Byte size of a INDX record. */
  164.     u8 cluster_size_bits;    /* Log(2) of the byte size of a cluster. */
  165.     u8 mft_record_size_bits;/* Log(2) of the byte size of a mft record. */
  166.     u8 indx_record_size_bits;/* Log(2) of the byte size of a INDX record. */
  167.  
  168.     /* Variables used by the cluster and mft allocators. */
  169.     u8 mft_zone_multiplier;    /* Initial mft zone multiplier. */
  170.     s64 mft_data_pos;    /* Mft record number at which to allocate the
  171.                    next mft record. */
  172.     LCN mft_zone_start;    /* First cluster of the mft zone. */
  173.     LCN mft_zone_end;    /* First cluster beyond the mft zone. */
  174.     LCN mft_zone_pos;    /* Current position in the mft zone. */
  175.     LCN data1_zone_pos;    /* Current position in the first data zone. */
  176.     LCN data2_zone_pos;    /* Current position in the second data zone. */
  177.  
  178.     s64 nr_clusters;    /* Volume size in clusters, hence also the
  179.                    number of bits in lcn_bitmap. */
  180.     ntfs_inode *lcnbmp_ni;    /* ntfs_inode structure for FILE_Bitmap. */
  181.     ntfs_attr *lcnbmp_na;    /* ntfs_attr structure for the data attribute
  182.                    of FILE_Bitmap. Each bit represents a
  183.                    cluster on the volume, bit 0 representing
  184.                    lcn 0 and so on. A set bit means that the
  185.                    cluster and vice versa. */
  186.  
  187.     LCN mft_lcn;        /* Logical cluster number of the data attribute
  188.                    for FILE_MFT. */
  189.     ntfs_inode *mft_ni;    /* ntfs_inode structure for FILE_MFT. */
  190.     ntfs_attr *mft_na;    /* ntfs_attr structure for the data attribute
  191.                    of FILE_MFT. */
  192.     ntfs_attr *mftbmp_na;    /* ntfs_attr structure for the bitmap attribute
  193.                    of FILE_MFT. Each bit represents an mft
  194.                    record in the $DATA attribute, bit 0
  195.                    representing mft record 0 and so on. A set
  196.                    bit means that the mft record is in use and
  197.                    vice versa. */
  198.  
  199.     int mftmirr_size;    /* Size of the FILE_MFTMirr in mft records. */
  200.     LCN mftmirr_lcn;    /* Logical cluster number of the data attribute
  201.                    for FILE_MFTMirr. */
  202.     ntfs_inode *mftmirr_ni;    /* ntfs_inode structure for FILE_MFTMirr. */
  203.     ntfs_attr *mftmirr_na;    /* ntfs_attr structure for the data attribute
  204.                    of FILE_MFTMirr. */
  205.  
  206.     ntfschar *upcase;    /* Upper case equivalents of all 65536 2-byte
  207.                    Unicode characters. Obtained from
  208.                    FILE_UpCase. */
  209.     u32 upcase_len;        /* Length in Unicode characters of the upcase
  210.                    table. */
  211.  
  212.     ATTR_DEF *attrdef;    /* Attribute definitions. Obtained from
  213.                    FILE_AttrDef. */
  214.     s32 attrdef_len;    /* Size of the attribute definition table in
  215.                    bytes. */
  216.  
  217.     s64 free_clusters;     /* Track the number of free clusters which
  218.                    greatly improves statfs() performance */
  219.     s64 free_mft_records;     /* Same for free mft records (see above) */
  220. };
  221.  
  222. extern ntfs_volume *ntfs_volume_alloc(void);
  223.  
  224. extern ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev,
  225.         unsigned long flags);
  226.  
  227. extern ntfs_volume *ntfs_device_mount(struct ntfs_device *dev,
  228.         unsigned long flags);
  229.  
  230. extern ntfs_volume *ntfs_mount(const char *name, unsigned long flags);
  231. extern int ntfs_umount(ntfs_volume *vol, const BOOL force);
  232.  
  233. extern int ntfs_version_is_supported(ntfs_volume *vol);
  234. extern int ntfs_volume_check_hiberfile(ntfs_volume *vol, int verbose);
  235. extern int ntfs_logfile_reset(ntfs_volume *vol);
  236.  
  237. extern int ntfs_volume_write_flags(ntfs_volume *vol, const u16 flags);
  238.  
  239. extern int ntfs_volume_error(int err);
  240.  
  241. #endif /* defined _NTFS_VOLUME_H */
  242.  
  243.